/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY. 
 * See the GNU General Public License for more details.
 * 
 * Copyright (C) 2011 CellObject.net
 */
package net.cellobject.javacodeformatter.view;

import net.cellobject.javacodeformatter.model.IFormatterItem;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

class FormatterViewLabelProvider extends LabelProvider implements ITableLabelProvider {
	public String getColumnText(final Object obj, final int index) {
		switch (index) {
			case 0: // Type column
				return "";
			case 1: // Name column
				if (obj instanceof IFormatterItem) {
					return ((IFormatterItem)obj).getName();
				}
				if (obj != null) {
					return obj.toString();
				}
				return "";
			case 2: // Location column
				if (obj instanceof IFormatterItem) {
					return ((IFormatterItem)obj).getLocation();
				}
				return "";
			default:
				return "";
		}
	}

	public Image getColumnImage(final Object obj, final int index) {
		if ( (index == 0) && (obj instanceof IFormatterItem)) {
			return ((IFormatterItem)obj).getType().getImage();
		}
		return null;
	}
}
